<script lang="ts" setup>
import { reactive } from 'vue'
import { ref } from 'vue'
import type { ImageProps } from 'element-plus'
import { Delete, Download, Plus, ZoomIn } from '@element-plus/icons-vue'

import type { UploadFile } from 'element-plus'

const dialogImageUrl = ref('')
const dialogVisible = ref(false)
const disabled = ref(false)

const handleRemove = (file: UploadFile) => {
    console.log(file)
}

const handlePictureCardPreview = (file: UploadFile) => {
    dialogImageUrl.value = file.url!
    dialogVisible.value = true
}

const handleDownload = (file: UploadFile) => {
    console.log(file)
}
const textarea = ref('')
const textarea1 = ref('')
const textarea2 = ref('')
const textarea3 = ref('')
const textarea4 = ref('')
const input = ref('')
const input1 = ref('')
const input2 = ref('')
const input3 = ref('')
const input4 = ref('')
const input5 = ref('')
const input6 = ref('')
const input7 = ref('')
const input8 = ref('')
const input9 = ref('')
const input10 = ref('')

// do not use same name with ref
const form = reactive({
    name: '',
    region: '',
    date1: '',
    date2: '',
    delivery: false,
    type: [],
    resource: '',
    desc: '',
})

const onSubmit = () => {
    console.log('submit!')
}
</script>

<template>
    <el-form :model="form" label-width="auto" style="max-width: 700px; color: black;">
        <el-form-item label="网站维护">
            <el-select v-model="form.region" placeholder="">
                <el-option label="打开" value="shanghai" />
                <el-option label="关闭" value="beijing" />
            </el-select>
            <h3>网站维护开启后，无法开启直播，进入直播间</h3>
        </el-form-item>
        <el-form-item label="维护提示" size="">
            <el-input v-model="textarea" :rows="2" type="textarea" placeholder="Please input" />
            <h3>维护提示信息（200字以内）</h3>
        </el-form-item>
        <el-form-item label="敏感词列表" size="">
            <el-input v-model="textarea1" :rows="2" type="textarea" placeholder="Please input" />
            <h3>多个以“|”分割</h3>
        </el-form-item>
        <el-form-item label="网站名称" size="">
            <el-input v-model="input" placeholder="Please input" />
            <h3>云端中国城</h3>
        </el-form-item>
        <el-form-item label="网站域名" size="">
            <el-input v-model="input1" placeholder="Please input" />
            <h3>格式：http(s)://xxx.com(:端口号)</h3>
        </el-form-item>
        <el-form-item label="版权信息" size="">
            <el-input v-model="textarea2" :rows="2" type="textarea" placeholder="Please input" />
            <h3>版权信息（200字以内）</h3>
        </el-form-item>
        <el-form-item label="砖石名称" size="">
            <el-input v-model="input2" placeholder="Please input" />
            <h3>用户充值得到的虚拟币名称</h3>
        </el-form-item>
        <el-form-item label="积分名称" size="">
            <el-input v-model="input3" placeholder="Please input" />
            <h3>直播间玩游戏得到的虚拟币名称</h3>
        </el-form-item>
        <el-form-item label="央票名称" size="">
            <el-input v-model="input4" placeholder="Please input" />
            <h3>主播得到的虚拟票名称</h3>
        </el-form-item>
        <el-form-item label="公司电话" size="">
            <el-input v-model="input5" placeholder="Please input" />
        </el-form-item>
        <el-form-item label="公司地址" size="">
            <el-input v-model="input6" placeholder="Please input" />
        </el-form-item>
        <el-form-item label="android版下载二维码" size="">
            <el-upload action="#" list-type="picture-card" :auto-upload="false">
                <el-icon>
                    <Plus />
                </el-icon>

                <template #file="{ file }">
                    <div>
                        <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
                        <span class="el-upload-list__item-actions">
                            <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
                                <el-icon><zoom-in /></el-icon>
                            </span>
                            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleDownload(file)">
                                <el-icon>
                                    <Download />
                                </el-icon>
                            </span>
                            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
                                <el-icon>
                                    <Delete />
                                </el-icon>
                            </span>
                        </span>
                    </div>
                </template>
            </el-upload>

            <el-dialog v-model="dialogVisible">
                <img w-full :src="dialogImageUrl" alt="Preview Image" />
            </el-dialog>
        </el-form-item>
        <el-form-item label="iPhone版下载二维码" size="">
            <el-upload action="#" list-type="picture-card" :auto-upload="false">
                <el-icon>
                    <Plus />
                </el-icon>
                <template #file="{ file }">
                    <div>
                        <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
                        <span class="el-upload-list__item-actions">
                            <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
                                <el-icon><zoom-in /></el-icon>
                            </span>
                            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleDownload(file)">
                                <el-icon>
                                    <Download />
                                </el-icon>
                            </span>
                            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
                                <el-icon>
                                    <Delete />
                                </el-icon>
                            </span>
                        </span>
                    </div>
                </template>
            </el-upload>

            <el-dialog v-model="dialogVisible">
                <img w-full :src="dialogImageUrl" alt="Preview Image" />
            </el-dialog>
        </el-form-item>
        <el-form-item label="微信公众号" size="">
            <el-upload action="#" list-type="picture-card" :auto-upload="false">
                <el-icon>
                    <Plus />
                </el-icon>
                <template #file="{ file }">
                    <div>
                        <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
                        <span class="el-upload-list__item-actions">
                            <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
                                <el-icon><zoom-in /></el-icon>
                            </span>
                            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleDownload(file)">
                                <el-icon>
                                    <Download />
                                </el-icon>
                            </span>
                            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
                                <el-icon>
                                    <Delete />
                                </el-icon>
                            </span>
                        </span>
                    </div>
                </template>
            </el-upload>
            <el-dialog v-model="dialogVisible">
                <img w-full :src="dialogImageUrl" alt="Preview Image" />
            </el-dialog>
        </el-form-item>
        <el-form-item label="官微A图标" size="">
            <el-upload action="#" list-type="picture-card" :auto-upload="false">
                <el-icon>
                    <Plus />
                </el-icon>
                <template #file="{ file }">
                    <div>
                        <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
                        <span class="el-upload-list__item-actions">
                            <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
                                <el-icon><zoom-in /></el-icon>
                            </span>
                            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleDownload(file)">
                                <el-icon>
                                    <Download />
                                </el-icon>
                            </span>
                            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
                                <el-icon>
                                    <Delete />
                                </el-icon>
                            </span>
                        </span>
                    </div>
                </template>
            </el-upload>
            <el-dialog v-model="dialogVisible">
                <img w-full :src="dialogImageUrl" alt="Preview Image" />
            </el-dialog>
        </el-form-item>
        <el-form-item label="官微A标题" size="">
            <el-input v-model="input7" placeholder="Please input" />
        </el-form-item>
        <el-form-item label="官微A标题" size="">
            <el-input v-model="textarea3" :rows="2" type="textarea" placeholder="Please input" />
        </el-form-item>
        <el-form-item label="官微A链接" size="">
            <el-input v-model="input8" placeholder="Please input" />
        </el-form-item>
        <el-form-item label="官微B图标" size="">
            <el-upload action="#" list-type="picture-card" :auto-upload="false">
                <el-icon>
                    <Plus />
                </el-icon>
                <template #file="{ file }">
                    <div>
                        <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
                        <span class="el-upload-list__item-actions">
                            <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
                                <el-icon><zoom-in /></el-icon>
                            </span>
                            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleDownload(file)">
                                <el-icon>
                                    <Download />
                                </el-icon>
                            </span>
                            <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
                                <el-icon>
                                    <Delete />
                                </el-icon>
                            </span>
                        </span>
                    </div>
                </template>
            </el-upload>
            <el-dialog v-model="dialogVisible">
                <img w-full :src="dialogImageUrl" alt="Preview Image" />
            </el-dialog>
        </el-form-item>
        <el-form-item label="官微B标题" size="">
            <el-input v-model="input9" placeholder="Please input" />
        </el-form-item>
        <el-form-item label="官微B标题" size="">
            <el-input v-model="textarea4" :rows="2" type="textarea" placeholder="Please input" />
        </el-form-item>
        <el-form-item label="官微B链接" size="">
            <el-input v-model="input10" placeholder="Please input" />
        </el-form-item>

    </el-form>

</template>


<style scoped>
.el-form-item h3 {
    color: #999;
    font-size: 12px;
}
</style>
